﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CsharpTrainer.Domain.Clients;
using CsharpTrainer.Model.Entities;
using Zeus.Thunder.Core;

namespace SharpTrainer.Collections
{
    class CopyListTest : ITestCase
    {
        public void Run()
        {
            EmployeesClient employeeClient = new EmployeesClient();
            List<Employee> srcEmployeeList = employeeClient.GetAllEmployees();

            Console.WriteLine("Source Employee List:");
            Console.WriteLine("--------------------------------------------------------------------");
            Display(srcEmployeeList);
            Console.WriteLine("--------------------------------------------------------------------");

            Console.WriteLine();
            Console.WriteLine();

            List<Employee> dstEmployeeList = new List<Employee>();
            srcEmployeeList.ForEach(emp => dstEmployeeList.Add((Employee)emp.Clone()));
            
            srcEmployeeList[0].LastName = "Huang";
            srcEmployeeList[0].FirstName = "Lynn";

            Console.WriteLine("Source Employee List After Change:");
            Console.WriteLine("--------------------------------------------------------------------");
            Display(srcEmployeeList);
            Console.WriteLine("--------------------------------------------------------------------");

            Console.WriteLine();
            Console.WriteLine();

            Console.WriteLine("Dest Employee List:");
            Console.WriteLine("--------------------------------------------------------------------");
            Display(dstEmployeeList);
            Console.WriteLine("--------------------------------------------------------------------");
        }

        private void Display(IList<Employee> employeeList)
        {
            foreach (Employee employee in employeeList)
            {
                Console.WriteLine(employee);
            }
        }
    }
}
